package com.qianli.user.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/3/3
 * Time: 下午12:00
 */
public enum SalaryEnum {
    UNDER_2000(1, "2000以下"),
    BETWEEN_2000_AND_4000(2, "2000-4000元"),
    BETWEEN_4000_AND_6000(3, "4000-6000元"),
    MORE_THAN_6000(4, "6000元以上");

    private Integer type;
    private String desc;

    SalaryEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public Integer getType() {
        return type;
    }

    public SalaryEnum setType(Integer type) {
        this.type = type;
        return this;
    }

    public String getDesc() {
        return desc;
    }

    public SalaryEnum setDesc(String desc) {
        this.desc = desc;
        return this;
    }

    public static List<String> getDescList() {
        List<String> list = new ArrayList<>();
        for (SalaryEnum enumObj : SalaryEnum.values()) {
            list.add(enumObj.getDesc());
        }
        return list;
    }

    public static SalaryEnum getEnumByType(Integer type) {
        SalaryEnum userSalaryEnum = null;
        for (SalaryEnum enumObj : SalaryEnum.values()) {
            if (enumObj.getType().equals(type)) {
                userSalaryEnum = enumObj;
                break;
            }
        }
        return userSalaryEnum;
    }
    
    public static SalaryEnum getEnumByDesc(String desc) {
        SalaryEnum userSalaryEnum = null;
        for (SalaryEnum enumObj : SalaryEnum.values()) {
            if (enumObj.getDesc().equals(desc)) {
                userSalaryEnum = enumObj;
                break;
            }
        }
        return userSalaryEnum;
    }
}
